package com.hrzyit.whistle.comm.presenter

import com.hrzyit.base.ext.execute
import com.hrzyit.base.presenter.BasePresenter
import com.hrzyit.base.rx.BaseObserver
import com.hrzyit.whistle.comm.data.bean.ContactEntity
import com.hrzyit.whistle.comm.presenter.view.ContactInfoView
import com.hrzyit.whistle.comm.service.IContactsService
import javax.inject.Inject

/**
 * 通讯录：人员信息详情 Presenter 逻辑
 * @author YangWei
 * @date 2019/5/7
 */
class ContactInfoPresenter @Inject constructor():BasePresenter<ContactInfoView>() {
    @Inject
    lateinit var contactsService: IContactsService

    /**
     * 获取人员信息详情
     * @author YangWei
     * @date 2019/5/7
     * @param   userId  用户id
     * @return 人员信息详情 {@link ContactEntity}
     */
    fun getContactUserDetail(userId: Long) {

        if (!checkNetWork()) {
            return
        }

        // 显示进度框
        mView.showLoading()

        contactsService.getContactUserDetail(userId)
            .execute(object : BaseObserver<ContactEntity>(mView) {
                override fun onNext(t: ContactEntity) {
                    mView.onGetContactUserDetailSuccess(t)
                }
            }, lifecycleProvider)
    }
}